package com.ruoyi.merchant.domain.dto;

import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 * 商家审核请求DTO
 */
@Data
public class MerchantAuditRequest {

    @NotNull(message = "商家ID不能为空")
    private Long merchantId;

    @NotBlank(message = "审核状态不能为空")
    @Pattern(regexp = "^(APPROVED|REJECTED)$", message = "审核状态只能是APPROVED或REJECTED")
    private String auditStatus;

    private String auditRemark;

    /**
     * 校验拒绝时必须填写原因
     */
    public void validate() {
        if ("REJECTED".equals(auditStatus)) {
            if (auditRemark == null || auditRemark.trim().isEmpty()) {
                throw new IllegalArgumentException("拒绝时必须填写拒绝原因");
            }
            if (auditRemark.length() > 500) {
                throw new IllegalArgumentException("拒绝原因不能超过500字");
            }
        }
    }
}
